<template>
	<view class="preview">
		<swiper circular>
			<swiper-item v-for="(item,index) in 10" :key="index">
				<image @click="maskChange" src="../../commons/images/preview2.jpg" mode="aspectFill"></image>
			</swiper-item>
		</swiper>

		<view class="mask" v-show="maskState">
			<!-- #ifndef MP-TOUTIAO -->
			<view class="goBack" @click="goBack" :style="{top:getStatusBarHeight()+'px'}">
				<uni-icons type="back" color="#fff" size="20"></uni-icons>
			</view>
			<!-- #endif -->
			<view class="count">3 / 9</view>
			<view class="time">
				<uni-dateformat :date="Date.now()" format="hh:mm"></uni-dateformat>
			</view>
			<view class="date">
				<uni-dateformat :date="Date.now()" format="MM月dd日"></uni-dateformat>
			</view>
			<view class="footer">
				<view class="box" @click="clickInfoPopup">
					<uni-icons type="info" size="28"></uni-icons>
					<view class="text">信息</view>
				</view>
				<view class="box" @click="clickScorePopup">
					<uni-icons type="star" size="28"></uni-icons>
					<view class="text">评分</view>
				</view>
				<view class="box">
					<uni-icons type="download" size="24"></uni-icons>
					<view class="text">下载</view>
				</view>
			</view>
		</view>

		<uni-popup ref="infoPopup" type="bottom" :is-mask-click="false">
			<view class="infoPopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸信息</view>
					<view class="close" @click="clickInfoPopupClose">
						<uni-icons type="closeempty" size="20" color="#999"></uni-icons>
					</view>
				</view>
				<scroll-view scroll-y>
					<view class="content">
						<view class="row">
							<view class="label">壁纸ID：</view>
							<text selectable class="value">123123123123</text>
						</view>
						<view class="row">
							<view class="label">分类：</view>
							<text selectable class="value classify">明星美女</text>
						</view>
						<view class="row">
							<view class="label">发布者：</view>
							<text selectable class="value">codeX</text>
						</view>
						<view class="row">
							<view class="label">评分：</view>
							<view class="value roteBox">
								<uni-rate touchable readonly value="3.5" size="16" />
								<text class="score">3.5分</text>
							</view>
						</view>
						<view class="row">
							<view class="label">摘要：</view>
							<text selectable class="value">1221312333311112213123333111111111
								11111133123123213123121221312333311111111111111133123123213123121111111111113312312321312312</text>
						</view>
						<view class="row">
							<view class="label">标签：</view>
							<view selectable class="value tabs">
								<view class="tab">明星美女</view>
								<view class="tab">猫猫</view>
								<view class="tab">狗狗</view>
							</view>
						</view>
						<view class="copyright">
							声明：本图片来用户投稿，非商业使用，用于免费学习交流，如侵犯了您的权益，您可以拷贝壁纸ID举报至平台，邮箱513894357@qq.com,管理将删除侵权壁纸，维护您的权益。
						</view>

					</view>
				</scroll-view>
			</view>
		</uni-popup>


		<uni-popup ref="scorePopup" type="center" :is-mask-click="false">
			<view class="scorePopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸评分</view>
					<view class="close" @click="clickScorePopupClose">
						<uni-icons type="closeempty" size="20" color="#999"></uni-icons>
					</view>
				</view>
				<view class="content">
					<uni-rate v-model="userScore" @change="onScoreChange" allow-half :size="28" />
					<text class="text">{{userScore}}分</text>
				</view>
				<view class="footer">
					<button @click="submitScore" type="default" size="mini" :disabled="!userScore" plain>确认评分</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		getStatusBarHeight
	} from "@/utils/system.js"

	const maskState = ref(true);

	const infoPopup = ref({})
	const scorePopup = ref({})
	const userScore = ref(0)

	// 确认评分
	const submitScore = () => {
		//TODO
	}

	// 关闭评分
	const clickScorePopupClose = () => {
		scorePopup.value.close();
	}

	// 点击评分
	const clickScorePopup = () => {
		scorePopup.value.open();
	}


	// 点击关闭信息弹窗
	const clickInfoPopupClose = () => {
		infoPopup.value.close();
	}


	// 点击显示信息弹窗
	const clickInfoPopup = () => {
		infoPopup.value.open();
	}


	// 遮罩弹窗
	const maskChange = () => {
		maskState.value = !maskState.value
	}


	const goBack = () => {
		uni.navigateBack({
			success: () => {

			},
			fail: (err) => {
				uni.reLaunch({
					url: "/pages/index/index"
				})
			}
		})
	}
</script>

<style scoped lang="scss">
	.preview {
		width: 100%;
		height: 100vh;
		position: relative;

		swiper {
			width: 100%;
			height: 100%;

			image {
				width: 100%;
				height: 100%;
			}

		}

		.mask {
			&>view {
				position: absolute;
				left: 0;
				right: 0;
				margin: auto;
				width: fit-content;
				color: #FFF;
			}

			.goBack {
				width: 38px;
				height: 38px;
				background: rgba(0, 0, 0, 0.5);
				left: 30rpx;
				margin-left: 0;
				border-radius: 100px;
				top: 0;
				backdrop-filter: blur(10rpx);
				border: 1rpx solid rgba(255, 255, 255, 0.3);
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.count {
				top: 10vh;
				background-color: rgba(0, 0, 0, .3);
				font-size: 28rpx;
				padding: 8rpx 28rpx;
				border-radius: 40rpx;
				backdrop-filter: blur(10rpx);
			}

			.time {
				font-size: 140rpx;
				top: calc(10vh + 80rpx);
				font-weight: 100;
				line-height: 1em;
				text-shadow: 0 4rpx rgba(0, 0, 0, .3);
			}

			.date {
				font-size: 34rpx;
				top: calc(10vh + 230rpx);
				text-shadow: 0 2rpx rgba(0, 0, 0, .3);
			}

			.footer {
				background: rgba(255, 255, 255, .8);
				bottom: 10vh;
				display: flex;
				justify-content: space-around;
				align-items: center;
				width: 65vw;
				height: 120rpx;
				border-radius: 120rpx;
				color: #333;
				box-shadow: 0 5rpx 0 rgba(0, 0, 0, .3);
				backdrop-filter: blur(10rpx);

				.box {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					padding: 2px 12rpx;

					.text {
						font-size: 26rpx;
						color: $text-font-color-2;
					}
				}
			}

		}

		.popHeader {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.title {
				font-size: 26rpx;
				color: $text-font-color-2;
			}

			.close {
				padding: 6rpx;
			}
		}

		.infoPopup {
			background: #FFF;
			padding: 30rpx;
			border-radius: 30rpx 30rpx 0 0;
			overflow: hidden;
			widows: 100%;

			scroll-view {
				max-height: 60vh;

				.content {
					.row {
						display: flex;
						padding: 16rpx 0;
						font-size: 32rpx;
						line-height: 1.7em;

						.label {
							color: $text-font-color-3;
							width: 140rpx;
							text-align: right;
							font-size: 30rpx;
						}

						.value {
							flex: 1;
							width: 0;
							font-size: 28rpx;
							color: #333;
						}

						.roteBox {
							display: flex;
							justify-content: left;
							align-items: center;

							.score {
								margin-left: 10rpx;
								font-size: 24rpx;
								color: $text-font-color-3;
							}
						}

						.tabs {
							display: flex;
							flex-wrap: wrap;

							.tab {
								border: 1px solid $brand-theme-color;
								color: $brand-theme-color;
								font-size: 22rpx;
								padding: 10rpx 30rpx;
								border-radius: 40rpx;
								line-height: 1.1em;
								margin: 0 10rpx 10rpx 0;
							}
						}

						.classify {
							color: $brand-theme-color;
						}
					}

					.copyright {
						font-size: 28rpx;
						padding: 20rpx;
						background: #f6f6f6;
						color: #666;
						border-radius: 10rpx;
						margin: 20rpx 0;
						line-height: 1.6em;
					}
				}
			}
		}

		.scorePopup {
			background-color: #FFF;
			width: 70vw;
			border-radius: 15rpx;

			.content {
				padding: 30rpx 0;
				display: flex;
				justify-content: center;
				align-items: center;

				.text {
					margin-left: 10rpx;
					color: #FFCA3E;
					line-height: 1em;
					width: 80rpx;
					text-align: right;
				}
			}
		}

		.footer {
			width: 100%;
			text-align: center;
			padding: 10rpx 0;
		}
	}
</style>